import org.kwis.msp.lcdui.Jlet;
import org.kwis.msp.lcdui.Display;

import org.kwis.msp.lwc.Component;
import org.kwis.msp.lwc.ContainerComponent;
import org.kwis.msp.lwc.ShellComponent   ;
import org.kwis.msp.lwc.ButtonComponent   ;

public class ContainerComponentEx1 extends Jlet{

	class ExtendedContainer extends ContainerComponent{

		public ExtendedContainer(){super();}

		protected void layout(){
			
			int numComponent = getNumberOfComponent();
			int height = getHeight();
			int width = getWidth();
			int widthComponent = width / numComponent;
			int heightComponent = height / numComponent;

			for(int i=0;i<numComponent;i++) {
				Component c = getComponent(i);
				//c.configure(2*i*(widthComponent/2),0,(widthComponent/2),height, POS_MASK | SIZE_MASK);
				c.configure(0,2*i*(heightComponent/2),width,(heightComponent/2), POS_MASK | SIZE_MASK);
			}
		}
		
	}


	Display displayLCD ;
	ShellComponent shell;	

	public ContainerComponentEx1(){  	}

	protected void startApp(String[] arg0){
		
		displayLCD = Display.getDefaultDisplay();
		shell = new ShellComponent();

		ButtonComponent button1 = new ButtonComponent("Button1",null);
		ButtonComponent button2 = new ButtonComponent("Button2",null);
		ButtonComponent button3 = new ButtonComponent("Button3",null);

		ExtendedContainer container = new ExtendedContainer();
		container.addComponent(button1);
		container.addComponent(button2);
		container.addComponent(button3);

		shell.setTitle("  Container Layout");
		shell.setWorkComponent(container);
		displayLCD.pushCard(shell.getCard());
	
	}
	protected void destroyApp(boolean arg0) {  }

}
